package com.twu.biblioteca;

import com.google.common.base.Objects;

import static com.google.common.base.Objects.equal;

public class Movie {
    private int year;
    private String name;
    private String director;
    private int rating;

    public Movie year(int year) {
        this.year = year;
        return this;
    }

    public int getYear() {
        return year;
    }

    public Movie name(String name) {
        this.name = name;
        return this;
    }

    public String getName() {
        return name;
    }

    public Movie director(String director) {
        this.director = director;
        return this;
    }

    public String getDirector() {
        return director;
    }

    public Movie rating(int rating) {
        this.rating = rating;
        return this;
    }

    public String getRating() {
        return rating == 0 ? "N/A" : String.valueOf(rating);
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Movie)) return false;
        Movie movie = (Movie) o;
        return equal(this.name, movie.name) && equal(this.director, movie.director) && equal(this.year, movie.year);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(name, director, year);
    }
}
